log using protestvotinglog

***cleaning data***
clear
import delimited "Hall_members.csv"
drop if chamber == "President"
keep if cong >= 51 & cong <= 117
rename state_abbrev state
rename congress cong
rename district_code dist
keep icpsr cong state dist
save "icpsr_dist.dta", replace

clear
import delimited "dime_recipients_1979_2024.csv", bindquote(strict)
keep if seat == "federal:house"
g wongeneral = gwinner == "W"
egen everwon = max(wongeneral), by(icpsr)
drop if everwon == 0
rename recipientcfscore cfscore
order icpsr cycle cfscore
sort icpsr cycle
egen id = group(icpsr)
egen meancf = mean(cfscore), by(icpsr2)
g match = meancf == cfscore
tab match
drop cfscore
rename meancf cfscore
drop icpsr
rename icpsr2 icpsr
order icpsr cfscore
sort icpsr
drop if icpsr == icpsr[_n-1]
drop if strpos(icpsr, "H") > 0
drop if strpos(icpsr, "S") > 0
drop if strpos(icpsr, "T") > 0
drop if strpos(icpsr, "C") > 0
drop if strpos(icpsr, "nyc") > 0
keep icpsr cfscore
destring icpsr, replace
save "cfscores.dta", replace

clear
postutil clear
import delimited "idealpoint_estimates_51-117.csv"
split member, p("(")
split member2, p(-)
rename member21 party
drop member1 member2 member22
g dem = party == "D"
g rep = party == "R"
*rescale scores so that Republicans are higher than Democrats, on average
*and rescale so that mean is 0 and stdev is 1 within every Congress
foreach i in expressive_ideal_idp ideal_idp expressive_wnominate_idp wnominate_idp {
egen meani = mean(`i'), by(cong)
egen sdi = sd(`i'), by(cong)
replace `i' = (`i' - meani)/sdi
drop meani sdi
g `i'dem = `i' if dem == 1
g `i'rep = `i' if rep == 1
egen meandem = mean(`i'dem), by(cong) 
egen meanrep = mean(`i'rep), by(cong)
replace `i' = `i'*-1 if meandem > meanrep
drop meandem meanrep `i'dem `i'rep
}
*code majority party
egen prdem = mean(dem), by(cong)
egen prrep = mean(rep), by(cong)
tab cong if prrep > prdem
/*
this gives us the correct majority party in all the Congresses we're studying
https://en.wikipedia.org/wiki/Party_leaders_of_the_United_States_House_of_Representatives
*/
g majority = 0
replace majority = 1 if prdem > prrep & dem == 1
replace majority = 1 if prrep > prdem & rep == 1
drop prdem prrep
*merge in CF scores
merge m:1 icpsr using "cfscores.dta"
tab cong _merge
drop if _merge == 2
drop _merge
*merge in data from Duck-Mayr and Montgomery
merge 1:1 icpsr cong using "mc3ggum.dta"
tab cong _merge
drop if _merge == 2
drop _merge

*merge in districts
merge 1:1 cong icpsr using "icpsr_dist.dta"
drop if _merge == 2
drop _merge
g eyear = 1788 + 2*cong
save "cleaneddata.dta", replace


***Figure 1***
clear
use "cleaneddata.dta"
keep if cong == 117
g squad = 0
replace squad = 1 if member == "Ocasio-Cortez (D-NY)"
replace squad = 1 if member == "Omar (D-MN)"
replace squad = 1 if member == "Pressley (D-MA)"
replace squad = 1 if member == "Tlaib (D-MI)"
replace squad = 1 if member == "Bowman (D-NY)"
replace squad = 1 if member == "Bush (D-MO)"
rename expressive_ideal_idp idealexp
rename ideal_idp ideal
g exp_squad = idealexp if squad == 1
g exp_dem = idealexp if party == "D" & squad == 0
g exp_rep = idealexp if party == "R"
graph twoway (lfit ideal ideal) (scatter exp_rep exp_dem exp_squad ideal)
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Standard Ideological Score
gr_edit .xaxis1.reset_rule -1.5 1.5 1 , tickset(major) ruletype(range) 
gr_edit .yaxis1.reset_rule -1.5 1.5 1 , tickset(major) ruletype(range)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Adjusted Ideological Score
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(gs8) pattern(dash)) editcopy
gr_edit .plotregion1.plot2.style.editstyle marker(size(medsmall) fillcolor(red) linestyle(color(red))) editcopy
gr_edit .plotregion1.plot3.style.editstyle marker(size(medsmall) fillcolor(blue) linestyle(color(blue))) editcopy
gr_edit .plotregion1.plot4.style.editstyle marker(size(medsmall) fillcolor(green) linestyle(color(green))) editcopy
gr_edit .plotregion1.AddTextBox added_text editor .799426399310031 .8899942324586996
gr_edit .plotregion1.added_text_new = 1
gr_edit .plotregion1.added_text_rec = 1
gr_edit .plotregion1.added_text[1].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[1].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[1].text = {}
gr_edit .plotregion1.added_text[1].text.Arrpush Republicans
gr_edit .plotregion1.added_text[1].style.editstyle color(red) editcopy
gr_edit .plotregion1.AddTextBox added_text editor -.834086153394805 -1.506961219740568
gr_edit .plotregion1.added_text_new = 2
gr_edit .plotregion1.added_text_rec = 2
gr_edit .plotregion1.added_text[2].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[2].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[2].text = {}
gr_edit .plotregion1.added_text[2].text.Arrpush Democrats
gr_edit .plotregion1.added_text[2].style.editstyle color(blue) editcopy
gr_edit .plotregion1.added_text[2].DragBy -.0300120416507453 .1551143332925046
gr_edit .plotregion1.AddTextBox added_text editor -1.55 -1.1
gr_edit .plotregion1.added_text_new = 3
gr_edit .plotregion1.added_text_rec = 3
gr_edit .plotregion1.added_text[3].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[3].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[3].text = {}
gr_edit .plotregion1.added_text[3].text.Arrpush Squad
gr_edit .plotregion1.added_text[3].style.editstyle color(green) editcopy
gr_edit .plotregion1.added_text[1].DragBy -.0042874345215341 -.0234134842705661
graph export "Squad.png", replace as(png)

***Figure 2***
clear
postutil clear
import delimited "data_for_118th_scatter.csv"
g dem = type == "Democrats"
g defector = type == "McCarthy defectors"
sum expressive
replace expressive = (expressive - r(mean))/r(sd)
sum ideal
replace ideal = (ideal - r(mean))/r(sd)
g exp_defector = expressive if defector == 1
g exp_dem = expressive if dem == 1
g exp_rep = expressive if dem == 0 & defector == 0
graph twoway (lfit ideal ideal) (scatter exp_rep exp_dem exp_defector ideal)
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Standard Ideological Score
gr_edit .xaxis1.reset_rule -2 1 1 , tickset(major) ruletype(range) 
gr_edit .yaxis1.reset_rule -2 2 1 , tickset(major) ruletype(range)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Adjusted Ideological Score
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(gs8) pattern(dash)) editcopy
gr_edit .plotregion1.plot2.style.editstyle marker(size(medsmall) fillcolor(red) linestyle(color(red))) editcopy
gr_edit .plotregion1.plot3.style.editstyle marker(size(medsmall) fillcolor(blue) linestyle(color(blue))) editcopy
gr_edit .plotregion1.plot4.style.editstyle marker(size(medsmall) fillcolor(green) linestyle(color(green))) editcopy
gr_edit .plotregion1.AddTextBox added_text editor .9 .4 
gr_edit .plotregion1.added_text_new = 1
gr_edit .plotregion1.added_text_rec = 1
gr_edit .plotregion1.added_text[1].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[1].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[1].text = {}
gr_edit .plotregion1.added_text[1].text.Arrpush Republicans
gr_edit .plotregion1.added_text[1].style.editstyle color(red) editcopy
gr_edit .plotregion1.AddTextBox added_text editor -.8 -1.4
gr_edit .plotregion1.added_text_new = 2
gr_edit .plotregion1.added_text_rec = 2
gr_edit .plotregion1.added_text[2].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[2].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[2].text = {}
gr_edit .plotregion1.added_text[2].text.Arrpush Democrats
gr_edit .plotregion1.added_text[2].style.editstyle color(blue) editcopy
gr_edit .plotregion1.AddTextBox added_text editor 1.9 .45
gr_edit .plotregion1.added_text_new = 3
gr_edit .plotregion1.added_text_rec = 3
gr_edit .plotregion1.added_text[3].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[3].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[3].text = {}
gr_edit .plotregion1.added_text[3].text.Arrpush McCarthy Defectors
gr_edit .plotregion1.added_text[3].style.editstyle color(green) editcopy
graph export "McCarthy.png", replace as(png)


***Figure 3***
clear
postutil clear
use "cleaneddata.dta"
keep if cong >= 97
postfile CF cong expressive nonexpressive pprob using "CF.dta", replace
forvalues i = 97/117 {
corr expressive_ideal_idp cfscore if majority == 1 & cong == `i'
scalar expressive = r(rho)
corr ideal_idp cfscore if majority == 1 & cong == `i'
scalar nonexpressive = r(rho)
sum express_ideal_pprob if majority == 1 & cong == `i'
post CF (`i') (expressive) (nonexpressive) (r(mean))
}
postclose CF
clear
use "CF.dta"
g greater = expressive > nonexpressive
graph twoway line expressive nonexpressive cong
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Congress
gr_edit .xaxis1.reset_rule 97 117 5, tickset(major) ruletype(range) 
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Correlation between RC and CF Scores
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(black) width(thick)) editcopy
gr_edit .plotregion1.plot2.style.editstyle line(color(gs8) width(thick)) editcopy
gr_edit .plotregion1.AddTextBox added_text editor .58 99
gr_edit .plotregion1.added_text_new = 1
gr_edit .plotregion1.added_text_rec = 1
gr_edit .plotregion1.added_text[1].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[1].style.editstyle color(gs8) editcopy
gr_edit .plotregion1.added_text[1].text = {}
gr_edit .plotregion1.added_text[1].text.Arrpush Standard
gr_edit .plotregion1.added_text[1].style.editstyle size(small) editcopy
gr_edit .plotregion1.AddTextBox added_text editor .67 100.5
gr_edit .plotregion1.added_text_new = 2
gr_edit .plotregion1.added_text_rec = 2
gr_edit .plotregion1.added_text[2].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[2].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[2].text = {}
gr_edit .plotregion1.added_text[2].text.Arrpush Adjusted
graph export "CFscores.png", replace as(png)

***Comparisons with GGUM, discussed in main text*** 
clear
postutil clear
use "cleaneddata.dta"
keep if cong >= 107 & cong <= 116
postfile CF cong expressive nonexpressive ggum using "CF.dta", replace
forvalues i = 107/116 {
corr expressive_ideal_idp cfscore if majority == 1 & cong == `i'
scalar expressive = r(rho)
corr ideal_idp cfscore if majority == 1 & cong == `i'
scalar nonexpressive = r(rho)
corr mc3ggum cfscore if majority == 1 & cong == `i'
scalar ggum = r(rho)
post CF (`i') (expressive) (nonexpressive) (ggum)
}
postclose CF
clear
use "CF.dta"
g ggumvsideal = ggum > nonexpressive
g expressivevsggum = expressive > ggum
tab ggumvs
tab expressivevs

***Figure 4***
clear
import delimited "expressive_ideal_expected_expressive_by_votes_51-117.csv"
split rollcall, p(_)
rename rollcall1 cong
destring cong, replace
rename rollcall2 bill
destring bill, replace
drop rollcall
g nbills = 1
g possible = eexpressive != 0
replace eexpressive = . if eexpressive == 0
collapse (mean) eexpressive (sum) possible nbills, by(cong) 
g prop_possible = possible/nbills
*numbers discussed in text
sum prop_possible [fw = nbills]
scalar ppossible = r(mean)
sum eexpressive [fw = possible]
scalar eee = r(mean)
disp 1/((eee*ppossible)/435)
*figure
graph twoway line eexpressive cong
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Congress
gr_edit .xaxis1.reset_rule 51 117 11 , tickset(major) ruletype(range) 
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Protest Votes Per Bill
gr_edit .yaxis1.reset_rule 0 6 2 , tickset(major) ruletype(range)
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(black) width(medthick)) editcopy
graph export "Eexpressive.png", replace as(png)

***Find bills where protest voting was pivotal, discussed in main text***
clear
import delimited "expressive_ideal_expected_expressive_by_votes_51-117.csv"
split rollcall, p(_)
rename rollcall1 cong
destring cong, replace
rename rollcall2 bill
destring bill, replace
drop rollcall rc_idx
drop vote_*
order cong bill eexpressive
save "ideal_eexpressive.dta", replace
clear
import delimited "Hall_rollcalls.csv"
keep if congress >= 51
keep congress rollnumber yea_count nay_count vote_desc vote_question
rename congress cong
rename rollnumber bill
merge 1:1 cong bill using "ideal_eexpressive.dta"
tab cong _merge
keep if _merge == 3
drop _merge
replace eexpressive = 0 if eexpressive == .
g margin = yea_count - nay_count
g pivotal = margin < 0 & eexpressive > margin*-1
browse if pivotal == 1

***Figure 5***
clear
postutil clear
use "cleaneddata.dta"
postfile Correlations cong ideal_majority using "Correlations.dta", replace
forvalues i = 51/117 {
corr expressive_ideal_idp ideal_idp if cong == `i' & majority == 1
scalar ideal_majority = r(rho)
post Correlations (`i') (ideal_majority)
}
postclose Correlations
clear
use "Correlations.dta"
graph twoway line ideal_majority cong
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Congress
gr_edit .xaxis1.reset_rule 51 117 11 , tickset(major) ruletype(range) 
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Correlation between Standard and Adjusted Estimates
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(black) width(medthick)) editcopy
graph export "IdeologyCorrelations.png", replace as(png)

***Appendix Figure 1***
clear
import delimited "stacked_idealpoints.csv"
split member_label, p("(")
split member_label2, p(-)
rename member_label21 party
drop if party == "I"
g dem = party == "D"
egen cong_dem = group(congress dem)
collapse *_idp congress dem, by(cong_dem)
drop cong_dem
rename stacked_ideal_idp ideal
rename stacked_ideal_exp_idp idealexp
rename stacked_wnom_idp nom
rename stacked_wnom_exp_idp nomexp
foreach i in ideal idealexp nom nomexp {
replace `i' = `i'*-1
}
reshape wide ideal idealexp nom nomexp, i(cong) j(dem)
foreach i in ideal idealexp nom nomexp {
g polarization_`i' = `i'0 - `i'1
}
g diff = polarization_idealexp - polarization_ideal
g demdiff = ideal1 - idealexp1
g repdiff = idealexp0 - ideal0
*Average difference in polarization between two measures
sum polarization_idealexp
scalar avgexp = r(mean)
sum polarization_ideal
disp avgexp/r(mean)
*Difference in average increase in polarization between two measures
sum polarization_idealexp if cong == 90
scalar start = r(mean)
sum polarization_idealexp if cong == 117
scalar increaseexp = r(mean) - start
sum polarization_ideal if cong == 90
scalar start = r(mean)
sum polarization_ideal if cong == 117
scalar increasestandard = r(mean) - start
disp increaseexp/increasestandard
*figure
graph twoway line ideal1 ideal0 idealexp1 idealexp0 congress
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Congress
gr_edit .xaxis1.reset_rule 51 117 11 , tickset(major) ruletype(range) 
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Estimated Ideology
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot2.style.editstyle line(color(red) width(medthick)) editcopy
gr_edit .plotregion1.plot4.style.editstyle line(color(maroon) width(medthick)) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(blue) width(medthick)) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(navy) width(medthick)) editcopy
gr_edit .plotregion1.AddTextBox added_text editor .9107055281641272 63.96248420282434
gr_edit .plotregion1.added_text_new = 1
gr_edit .plotregion1.added_text_rec = 1
gr_edit .plotregion1.added_text[1].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[1].style.editstyle color(red) editcopy
gr_edit .plotregion1.added_text[1].text = {}
gr_edit .plotregion1.added_text[1].text.Arrpush Republicans (standard)
gr_edit .plotregion1.added_text[1].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[1].DragBy -.1030545221960519 -1.224028558022152
gr_edit .plotregion1.added_text[1].DragBy .0154581783294083 -.5245836677237908
gr_edit .plotregion1.AddTextBox added_text editor 1.266243629740505 63.02989101575984
gr_edit .plotregion1.added_text_new = 2
gr_edit .plotregion1.added_text_rec = 2
gr_edit .plotregion1.added_text[2].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[2].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[2].text = {}
gr_edit .plotregion1.added_text[2].text.Arrpush Republicans (adjusted)
gr_edit .plotregion1.added_text[2].style.editstyle color(maroon) editcopy
gr_edit .plotregion1.added_text[2].DragBy -.0618327133176323 .4662965935322422
gr_edit .plotregion1.added_text[1].DragBy .0515272610980255 -4.604678861130964
gr_edit .plotregion1.AddTextBox added_text editor -.5526686870198043 69.20832088006213
gr_edit .plotregion1.added_text_new = 3
gr_edit .plotregion1.added_text_rec = 3
gr_edit .plotregion1.added_text[3].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[3].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[3].text = {}
gr_edit .plotregion1.added_text[3].text.Arrpush Democrats (standard)
gr_edit .plotregion1.added_text[3].style.editstyle color(blue) editcopy
gr_edit .plotregion1.AddTextBox added_text editor -.5423632348001988 75.96962148627976
gr_edit .plotregion1.added_text_new = 4
gr_edit .plotregion1.added_text_rec = 4
gr_edit .plotregion1.added_text[4].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[3].DragBy -.0154581783294079 -5.478984974003945
gr_edit .plotregion1.added_text[3].DragBy -.0154581783294083 -1.748612225745935
gr_edit .plotregion1.AddTextBox added_text editor -.9648867758040098 64.31220664797353
gr_edit .plotregion1.added_text_new = 5
gr_edit .plotregion1.added_text_rec = 5
gr_edit .plotregion1.added_text[5].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[5].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[5].text = {}
gr_edit .plotregion1.added_text[5].text.Arrpush Democrats (adjusted)
gr_edit .plotregion1.added_text[5].style.editstyle color(navy) editcopy
gr_edit .plotregion1.added_text[5].DragBy -.0154581783294081 -.3497224451491953
graph save "Polarization1.gph", replace
graph twoway line demdiff repdiff congress
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Congress
gr_edit .xaxis1.reset_rule 51 117 11 , tickset(major) ruletype(range) 
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Difference in Estimated Extremism
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(blue) width(medthick)) editcopy
gr_edit .plotregion1.plot2.style.editstyle line(color(red) width(medthick)) editcopy
gr_edit .plotregion1.AddTextBox added_text editor .024 54
gr_edit .plotregion1.added_text_new = 1
gr_edit .plotregion1.added_text_rec = 1
gr_edit .plotregion1.added_text[1].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[1].style.editstyle color(blue) editcopy
gr_edit .plotregion1.added_text[1].text = {}
gr_edit .plotregion1.added_text[1].text.Arrpush Democrats
gr_edit .plotregion1.added_text[1].style.editstyle size(small) editcopy
gr_edit .plotregion1.AddTextBox added_text editor .056 55
gr_edit .plotregion1.added_text_new = 2
gr_edit .plotregion1.added_text_rec = 2
gr_edit .plotregion1.added_text[2].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[2].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[2].style.editstyle color(red) editcopy
gr_edit .plotregion1.added_text[2].text = {}
gr_edit .plotregion1.added_text[2].text.Arrpush Republicans
graph save "Polarization2.gph", replace
graph twoway line polarization_ideal polarization_idealexp congress
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Congress
gr_edit .xaxis1.reset_rule 51 117 11 , tickset(major) ruletype(range) 
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Estimated Polarization
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(gs8) width(medthick)) editcopy
gr_edit .plotregion1.plot2.style.editstyle line(color(black) width(medthick)) editcopy
gr_edit .plotregion1.AddTextBox added_text editor 1.75 64.5
gr_edit .plotregion1.added_text_new = 1
gr_edit .plotregion1.added_text_rec = 1
gr_edit .plotregion1.added_text[1].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[1].style.editstyle color(gs8) editcopy
gr_edit .plotregion1.added_text[1].text = {}
gr_edit .plotregion1.added_text[1].text.Arrpush Standard
gr_edit .plotregion1.added_text[1].style.editstyle size(small) editcopy
gr_edit .plotregion1.AddTextBox added_text editor 2 66
gr_edit .plotregion1.added_text_new = 2
gr_edit .plotregion1.added_text_rec = 2
gr_edit .plotregion1.added_text[2].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[2].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[2].text = {}
gr_edit .plotregion1.added_text[2].text.Arrpush Adjusted
graph save "Polarization3.gph", replace
graph twoway line diff congress
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Congress
gr_edit .xaxis1.reset_rule 51 117 11 , tickset(major) ruletype(range) 
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Difference in Estimated Polarization
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(black) width(medthick)) editcopy
graph save "Polarization4.gph", replace
graph combine "Polarization1.gph" "Polarization2.gph" "Polarization3.gph" "Polarization4.gph", col(2)
gr_edit .style.editstyle margin(zero) editcopy
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
gr_edit .style.editstyle boxstyle(linestyle(color(white))) editcopy
gr_edit .plotregion1.graph1.yaxis1.title.style.editstyle size(small) editcopy
gr_edit .plotregion1.graph2.yaxis1.title.style.editstyle size(small) editcopy
gr_edit .plotregion1.graph3.yaxis1.title.style.editstyle size(small) editcopy
gr_edit .plotregion1.graph4.yaxis1.title.style.editstyle size(small) editcopy
gr_edit .plotregion1.graph1.xaxis1.title.draw_view.setstyle, style(no)
gr_edit .plotregion1.graph2.xaxis1.title.draw_view.setstyle, style(no)
gr_edit .plotregion1.graph1.plotregion1.added_text[2].DragBy .1823123707348621 -.4211735607050578
gr_edit .plotregion1.graph2.plotregion1.added_text[1].DragBy -.0032305729073626 -1.181986828942222
gr_edit .plotregion1.graph1.plotregion1.added_text[5].DragBy -.1823123707348642 -3.895855436521797
gr_edit .plotregion1.graph3.plotregion1.added_text[2].DragBy .223063367413133 -1.396893525113504
gr_edit .plotregion1.graph3.xaxis1.title.style.editstyle size(small) editcopy
gr_edit .plotregion1.graph4.xaxis1.title.style.editstyle size(small) editcopy
graph export "Polarization.png", replace as(png)

***Appendix Table 1***
clear
use "cleaneddata.dta"
*drop if multiple people served in the same seat (or there were multimember dists)
duplicates tag state dist eyear, g(repeat)
keep if repeat == 0
drop repeat
tostring dist, replace
replace dist = state + "-" + dist
drop state
merge 1:1 dist eyear using "Pres_CD_1952_2020.dta"
tab eyear _merge
keep if _merge == 3
drop _merge
rename pres presvs
egen party_year = group(dem rep eyear)
lab var presvs "Presidential Vote Share"
lab var ideal_idp "Ideology (standard)"
lab var expressive_ideal_idp "Ideology (adjusted)"
est clear
eststo: areg ideal_idp presvs, a(eyear) cluster(icpsr)
eststo: areg expressive_ideal_idp presvs, a(eyear) cluster(icpsr)
eststo: areg ideal_idp presvs, a(party_year) cluster(icpsr)
eststo: areg expressive_ideal_idp presvs, a(party_year) cluster(icpsr)
esttab using representation.tex, replace b(3) se(3) r2 nomtitle label star(* .05 ** .01)

***Appendix Tables 2, 3, and 4***
clear
import delimited "house_member_campaign_receipts.csv"
rename year eyear
*drop duplicate cases (one case where a child mistakenly got matched to the same icpsr code, another where someone switched parties)
drop if eyear == 2004 & fecname == "tauzin, wilbert j iii"
drop if fecname == "fish, hamilton jr" & cand_pty_affiliation == "DEM"
duplicates report eyear icpsr
drop congress bioname cand_pty state cd district
save "fec_receipts.dta", replace
clear
use "cleaneddata.dta"
*drop redistricting years
drop if eyear - 2 == floor(eyear/10)*10
*drop if multiple people served in the same seat (or there were multimember dists)
duplicates tag state dist eyear, g(repeat)
keep if repeat == 0
drop repeat
merge 1:1 state dist eyear using "HouseVoteShares.dta"
tab eyear _merge
keep if _merge == 3
drop _merge
g cycle = floor((eyear - 4)/10)*10 + 4
g extremism1 = ideal_idp
replace extremism1 = ideal_idp*-1 if dem == 1
g extremism2 = expressive_ideal_idp
replace extremism2 = expressive_ideal_idp*-1 if dem == 1
tostring dist, replace
replace dist = state + "-" + dist
drop state
merge 1:1 dist eyear using "Pres_CD_1952_2020.dta"
tab eyear _merge
keep if _merge == 3
drop _merge
rename pres presvs
*recode presvs to be in the direction of the member
replace presvs = presvs*-1 if dem == 1
rename presvs presvoteshare
keep if eyear >= 1954
egen party_year = group(eyear dem)
*Appendix Table 2
lab var incvoteshare "Incumbent Vote Share"
lab var extremism1 "Extremism (standard)"
lab var extremism2 "Extremism (adjusted)"
lab var express_ideal_pprob "Protest Voting"
lab var presvoteshare "Presidential Vote Share"
est clear
eststo: areg incvoteshare extremism1 presvoteshare, a(party_year) cluster(icpsr)
eststo: areg incvoteshare extremism2 presvoteshare, a(party_year) cluster(icpsr)
eststo: areg incvoteshare extremism1 extremism2 presvoteshare, a(party_year) cluster(icpsr)
eststo: areg incvoteshare extremism1 extremism2 presvoteshare if majority == 1, a(party_year) cluster(icpsr)
eststo: areg incvoteshare extremism2 express_ideal_pprob presvoteshare, a(party_year) cluster(icpsr)
esttab using electoral.tex, replace b(3) se(3) nomtitle label star(* .05 ** .01) ar2
*Appendix Table 3
sum cong
g time = (cong - r(min))/(r(max) - r(min))
g extremism1_time = extremism1*time
g extremism2_time = extremism2*time
g pprob_time = express_ideal_pprob*time
lab var incvoteshare "Incumbent Vote Share"
lab var extremism1 "Extremism (standard)"
lab var extremism2 "Extremism (adjusted)"
lab var express_ideal_pprob "Protest Voting"
lab var presvoteshare "Presidential Vote Share"
lab var extremism1_time "Extremism (standard)*Time"
lab var extremism2_time "Extremism (adjusted)*Time"
lab var pprob_time "Protest Voting*Time"
lab var time "Time"
est clear
eststo: areg incvoteshare extremism1 extremism1_time presvoteshare, a(party_year) cluster(icpsr)
eststo: areg incvoteshare extremism2 extremism2_time presvoteshare, a(party_year) cluster(icpsr)
eststo: areg incvoteshare extremism1 extremism2 extremism1_time extremism2_time presvoteshare, a(party_year) cluster(icpsr)
eststo: areg incvoteshare extremism1 extremism2 extremism1_time extremism2_time presvoteshare if majority == 1, a(party_year) cluster(icpsr)
eststo: areg incvoteshare extremism2 express_ideal_pprob extremism2_time pprob_time presvoteshare, a(party_year) cluster(icpsr)
esttab using electoral_time.tex, replace b(3) se(3) nomtitle label star(* .05 ** .01) ar2
*Appendix Table 4
merge 1:1 icpsr eyear using "FEC_receipts.dta"
keep if _merge == 3
drop _merge
order member fecname
replace ttl_receipts = ttl_receipts/1000
g logreceipts = log(ttl_receipts + 1)
egen party_cycle = group(eyear dem)
sum party_cycle
local npartycycles = r(max)
g pincvote = .
forvalues i = 1/`npartycycles' {
reg incvoteshare presvoteshare if party_cycle == `i'
predict temp
replace pincvote = temp if party_cycle == `i'
drop temp
}
g pcompetitiveness = 1 - abs(pincvote - .5)*2
lab var incvoteshare "Incumbent Vote Share"
lab var extremism1 "Extremism (standard)"
lab var extremism2 "Extremism (adjusted)"
lab var express_ideal_pprob "Protest Voting"
lab var presvoteshare "Presidential Vote Share"
lab var pcompetitiveness "Predicted Competitiveness"
est clear
eststo: areg logreceipts extremism1 pcompetitiveness, a(party_year) cluster(icpsr)
eststo: areg logreceipts extremism2 pcompetitiveness, a(party_year) cluster(icpsr)
eststo: areg logreceipts extremism1 extremism2 pcompetitiveness, a(party_year) cluster(icpsr)
eststo: areg logreceipts extremism1 extremism2 pcompetitiveness if majority == 1, a(party_year) cluster(icpsr)
eststo: areg logreceipts extremism2 express_ideal_pprob pcompetitiveness, a(party_year) cluster(icpsr)
esttab using fundraising.tex, replace b(3) se(3) nomtitle label star(* .05 ** .01) ar2


***Appendix Figure 9***
clear
postutil clear
use "cleaneddata.dta"
keep if cong >= 97
postfile CF cong expressive nonexpressive using "CF.dta", replace
forvalues i = 97/117 {
corr expressive_wnominate_idp cfscore if majority == 1 & cong == `i'
scalar expressive = r(rho)
corr wnominate_idp cfscore if majority == 1 & cong == `i'
scalar nonexpressive = r(rho)
post CF (`i') (expressive) (nonexpressive)
}
postclose CF
clear
use "CF.dta"
g greater = expressive > nonexpressive
tab greater
sum
graph twoway line expressive nonexpressive cong
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Congress
gr_edit .xaxis1.reset_rule 97 117 5, tickset(major) ruletype(range) 
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Correlation between NOMINATE and CF Scores
gr_edit .yaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .xaxis1.style.editstyle majorstyle(gridstyle(linestyle(color(white)))) editcopy
gr_edit .style.editstyle declared_ysize(4) editcopy
gr_edit .style.editstyle declared_xsize(5.5) editcopy
gr_edit .style.editstyle margin(vsmall) boxstyle(shadestyle(color(white)) linestyle(color(white))) editcopy
gr_edit .plotregion1.plot1.style.editstyle line(color(black) width(thick)) editcopy
gr_edit .plotregion1.plot2.style.editstyle line(color(gs8) width(thick)) editcopy
gr_edit .plotregion1.AddTextBox added_text editor .58 99
gr_edit .plotregion1.added_text_new = 1
gr_edit .plotregion1.added_text_rec = 1
gr_edit .plotregion1.added_text[1].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[1].style.editstyle color(gs8) editcopy
gr_edit .plotregion1.added_text[1].text = {}
gr_edit .plotregion1.added_text[1].text.Arrpush Standard
gr_edit .plotregion1.added_text[1].style.editstyle size(small) editcopy
gr_edit .plotregion1.AddTextBox added_text editor .67 100.5
gr_edit .plotregion1.added_text_new = 2
gr_edit .plotregion1.added_text_rec = 2
gr_edit .plotregion1.added_text[2].style.editstyle  angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(bluishgray) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[2].style.editstyle size(small) editcopy
gr_edit .plotregion1.added_text[2].text = {}
gr_edit .plotregion1.added_text[2].text.Arrpush Adjusted
graph export "CF_nom.png", replace as(png)

log close
translate protestvotinglog.smcl protestvotinglog.pdf


